package com.xxx.video.dynamic.activitys;

import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.xxx.video.R;
import com.xxx.video.commen.activitys.BaseActivity;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.utils.ListUtils;
import com.xxx.video.commen.utils.StatusBarUtil;
import com.xxx.video.dynamic.adapters.MyGetFriendRequestAdapter;
import com.xxx.video.dynamic.beans.ReceiverFriendListBean;
import com.xxx.video.dynamic.presenters.IMyGetFriendRequestView;
import com.xxx.video.dynamic.presenters.MyGetFriendRequestPresenter;

import butterknife.BindView;

public class MyGetFriendRequestActivity extends BaseActivity<MyGetFriendRequestPresenter>
        implements IMyGetFriendRequestView, BaseRecycleViewAdapter.OnItemClickListener<ReceiverFriendListBean.PageBean.ListBean> {
    @BindView(R.id.rcv_my_get_friend_request_list)
    RecyclerView rcvMyGetFriendRequestList;

    @Override
    public void initToolbarData() {
        super.initToolbarData();
        showActionBar();
        StatusBarUtil.getInstance().setStatusBarTransparent(this, true);
        setIsShowActionbarLine(true);
        setActionBarTitle(R.string.title_my_get_friend_request_activity);
    }

    @Override
    protected MyGetFriendRequestPresenter createPresenter() {
        return new MyGetFriendRequestPresenter(this, this);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_my_get_friend_request;
    }

    @Override
    public void initData(Bundle extras) {
        getPresenter().getReceivedFriendsList();
    }

    @Override
    public void showRootLayoutStatus(int status) {
        showLayoutStatus(status);
    }

    @Override
    public void initData2View(ReceiverFriendListBean.PageBean page) {
        showRootLayoutStatus(1);
        rcvMyGetFriendRequestList.setLayoutManager(new LinearLayoutManager(this));
        MyGetFriendRequestAdapter myGetFriendRequestAdapter = new MyGetFriendRequestAdapter(this);
        myGetFriendRequestAdapter.setOnItemClickListener(this);
        rcvMyGetFriendRequestList.setAdapter(myGetFriendRequestAdapter);
        myGetFriendRequestAdapter.setData(page.list);
        if (ListUtils.isEmpty(page.list)) {
            showRootLayoutStatus(2);
        }
    }

    @Override
    public void acceptFriendsSuccess() {

    }

    @Override
    public void unAgreeSuccess() {

    }

    @Override
    public void onItemClick(ReceiverFriendListBean.PageBean.ListBean listBean, int position, int type) {
        if (type == 1) {
            /*
             * un agree
             */
            getPresenter().refuse(listBean.fId);
        } else if (type == 2) {
            /*
             *  agree
             */
            getPresenter().acceptFriends(listBean.fId);
        }
    }
}
